/*  Functions for fields after change events */

// Handle after change events. That is a formula or a remote call.
function handleAfterChange(fieldName) {
    srcTag = extractTag(fieldName);
    event_def = eval('dzAC_'+srcTag);
    actionArr = event_def.split(";");
    iCount = actionArr.length;
    for (c = 0; c < iCount; c++ ) {
        action = actionArr[c].split("://");
        switch (action[0]) {
            case 'rpc':
                afterChangeRCall(fieldName, action[1]);
                break;

            case 'irpc':
                submitNalle("nalle", fieldName, "EIrpc", action[1]);
                break;

            default:
                dzCalculate(fieldName, action[0]);
        }
    } // for
} // handleAfterChange

/*
 *  Function to handle after change event remote call
 *  PARAMS:
 *      field   The name of the field that triggered the event
 *      actionStr  String that contains parameter and result colums tags and
 *                  remote host address
 */
function afterChangeRCall(field, actionStr) {
    /* First replace the tcolumn tags with real field names */
    actionStr = dzReplaceTags(field, actionStr);
    /* Call remote script */
    doRCall(actionStr, "handleACRCallRes");
} // afterChangeRCall


/*
 *  Function to handle after change event remote call results
 *  PARAMS:
 *      results   String containing results. Results are "/dz&" separated
 */
function handleACRCallRes(results) {
    resultArr = results.split('/dz&');
    aCount = resultArr.length;

    for (c = 0; c < aCount; c++) {
        eval(resultArr[c]);
    } // for
} // handleACRCallRes
